/**
 * 版权所有 违者必究
 * by chenxh
 */
package com.site.base.entity;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.lang.reflect.Field;

/**
 *<br><b>类描述:</b>
 *<br>所有领域对象的基类
 *@see
 *@since
 */
public class BaseObject implements Serializable 
{
    /*日志记录器*/
    protected Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 创建时间
     */
    protected String createTime;

    /**
     * 更新时间
     */
    protected String updateTime;

    /**
     * 更新键
     */
    protected String updateKey;

    protected int version = 1;

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public String getUpdateKey() {
        return updateKey;
    }

    public void setUpdateKey(String updateKey) {
        this.updateKey = updateKey;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    /**
     * 仅输出原始数据类型及字符串类型的属性
     * @return
     */
    @Override
    public String toString() {
        return (new ReflectionToStringBuilder(this) {
            protected boolean accept(Field f) {
                if(f.getType().isPrimitive() || f.getType() == String.class ){
                    return true;
                }else{
                    return false;
                }
            }
        }).toString();
    }
}
